package com.api.shopapi.mapper;

import com.api.shopapi.entity.DishesPlanMorning;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface DishesPlanMorningMapper {


    @Insert("insert into dishes_plan_morning" +
            "(" +
            "DishesPlanMorningCode," +
            "DishesPlanCode" +
            ") " +
            "values" +
            "(" +
            "#{dishesPlanMorning.DishesPlanMorningCode}," +
            "#{dishesPlanMorning.DishesPlanCode}" +
            ")")
    int insert(@Param("dishesPlanMorning") DishesPlanMorning dishesPlanMorning);

    @Delete("delete from dishes_plan_morning where dishesPlanMorningCode=#{dishesPlanMorningCode}")
    int delete(@Param("dishesPlanMorningCode") String dishesPlanMorningCode);

    @Update("update dishes_plan_morning" +
            " set" +
            " DishesPlanCode=#{dishesPlanMorning.DishesPlanCode}" +
            " where " +
            " DishesPlanMorningCode=#{dishesPlanMorning.DishesPlanMorningCode}")
    int update(@Param("dishesPlanMorning") DishesPlanMorning dishesPlanMorning);

    @Select("select * from dishes_plan_morning where dishesPlanMorningCode=#{dishesPlanMorningCode} limit 1")
    DishesPlanMorning getByDishesPlanMorningCode(@Param("dishesPlanMorningCode") String dishesPlanMorningCode);

    @Select("<script>" +
            "select * from dishes_plan_morning where dishesPlanCode=#{dishesPlanCode} " +
            "</script>")
    List<DishesPlanMorning> ListByDishesPlanCode(@Param("dishesPlanCode") String dishesPlanCode);

}
